package com.git_taoxian.test4;

public class CalculatorDemo {
    public static void main(String[] args) {
//        生成接口的子类对象
//        Calculator calculator = new Calculator() {
//            @Override
//            public String calc(String str) {
//                return str;
//            }
//        };
//        Lambda表达式
        Calculator calculator = str-> str;
//        生成当前的类的对象
        CalculatorDemo calculatorDemo = new CalculatorDemo();
        String newStr = calculatorDemo.useCalculator(calculator, "你好啊");
        System.out.println(newStr);
    }
//    方法useCalculator
    public String useCalculator(Calculator calculator,String str){
        String rs = calculator.calc(str);
        return rs;
    }
}
